<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ReplyContent extends Model
{
    protected $fillable = ['doctor_id','content','evaluates_id'];
    protected $table = "c_reply_contents";

    /**
     * @param $filter
     * @return mixed
     * 添加/编辑
     */
    public function add($filter)
    {

        if (isset($filter['id'])) {
            unset($filter['api_token']);
            return $this::where([['id', '=', $filter['id']]])->update($filter);
        } else {
            $res = $this->where([['evaluates_id', '=', $filter['evaluates_id']]])->first();
            if ($res) {
                return "该评论已被回复,不能重复回复!";
            }
            $result = $this->create($filter);
            if ($result) {
                return true;
            }
        }
    }


}
